object ForGuardDemo extends App {
  // 定义班级英语成绩
  val englishScores: Array[Int] = Array(75, 58, 90, 65, 52, 88, 72, 45, 68, 70, 59, 82)

  // 初始化变量
  var passCount = 0
  val totalStudents = englishScores.length
  val passScores = collection.mutable.ListBuffer[Int]()

  // 使用for循环守卫筛选及格成绩
  for (score <- englishScores if score >= 60) {
    passCount += 1
    passScores += score
    println(s"及格成绩: $score")
  }

  // 计算及格率
  val passRate = (passCount.toDouble / totalStudents) * 100

  // 输出结果
  println(s"\n及格成绩列表: $passScores")
  println(s"及格人数: $passCount/$totalStudents")
  printf("及格率:%.1f%%",passRate)

  for (score <- englishScores if score>= 80 && score <= 90) {println (s"良好成绩: $score")}
}